package com.ymatou.iapi.login.testcase;

import java.io.IOException;
import java.security.interfaces.RSAPublicKey;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.ymatou.iapi.deviceid.parameter.SaveBean;
import com.ymatou.iapi.deviceid.service.SaveCall;
import com.ymatou.iapi.login.parameter.LoginAuthBean;
import com.ymatou.iapi.login.service.LoginAuthCall;
import com.ymatou.iapi.userregister.parameter.SellerRegisterBean;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.core.tool.RSAUtils;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.data.LoginSafeConfiguration;
import com.ymttest.business.service.DeviceidCallService;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.business.service.JUserSafe;
import com.ymttest.business.service.LiveShopUserCallService;
import com.ymttest.database.model.LoginLog;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.mongo.MongoLoginHistoryWapper;
import com.ymttest.database.mongo.ULC201406Bean;
import com.ymttest.database.mongo.ULC201406Wapper;
import com.ymttest.database.mongo.UserTokenWapper;
import com.ymttest.database.mongo.YmatouBlacklistUserWapper;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.database.sqlwapper.LoginHistoryWapper;
import com.ymttest.database.sqlwapper.UserSafeWapper;
import com.ymttest.database.sqlwapper.YmtUsersWapper;
import com.ymttest.utils.DesUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 * 登入认证 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_LoginAuth {
	private static LoginAuthBean lab;
	private static LoginAuthCall lac;
	private UserSafeWapper authWapper;
	private ULC201406Wapper userWapper;
	private UserTokenWapper userTokenWapper;
	private static MongoLoginHistoryWapper mloginHistoryWapper;
	private static YmatouBlacklistUserWapper ymtblacklistuserWapper;
	private static boolean DELETELOGINHISTORY = true;
	// 刷新配置重试次数，测试环境需要5秒刷新
	int ret = 5;

	@BeforeClass
	public static void setUp() throws Exception {
		Logger.createResultFile("登入认证");
		mloginHistoryWapper = new MongoLoginHistoryWapper();
		ymtblacklistuserWapper = new YmatouBlacklistUserWapper();
	}

	@Before
	public void caseUp() throws Exception {
		lab = new LoginAuthBean();
		lac = new LoginAuthCall();
		authWapper = new UserSafeWapper();
		userWapper = new ULC201406Wapper();
		userTokenWapper = new UserTokenWapper();
		JUserCallService.initUserSafeConfig();
	}

	@AfterClass
	public static void tearDown() throws Throwable {
		Logger.generateResult(lac.getOpurl());

	}

	@After
	public void caseDown() throws Throwable {
		Logger.end();
		JUserSafe.initConfig(1);
		// userWapper.close();
		// blackLisWapper.close();
		// authWapper.close();
		// mloginHistoryWapper.close();
		// ymtblacklistuserWapper.close();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_001() {
		Logger.start(true, "注册用户第一次在PC端登陆，登入认证成功");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setTokenSource("app");
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(token, lac.getUserData().getSign(), "验证Token信息-登入重新生成");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(UserId).get(0);

			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regbean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_002() {
		Logger.start(false, "输入错误LoginId失败");
		try {
			lab.setLoginId("nobody1");
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setClientIp(TestDataManager.getRandomIp());
			lac.setData(lab);
			lab.setSourceType("app");
			lac.callService();
			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("LoingIdOrPasError", new JSONObject(lac.getString("Result")).get("Code"), "验证Code信息");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_003() {
		Logger.start(false, "输入错误项Pas失败");
		try {
			lab.setLoginId("15216713145");
			lab.setPas("12345");
			lab.setClientIp(TestDataManager.getRandomIp());
			lac.setData(lab);
			lab.setSourceType("app");
			lac.callService();
			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("LoingIdOrPasError", new JSONObject(lac.getString("Result")).get("Code"), "验证Code信息");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_004() {
		Logger.start(true, "风控验证-buyerEnableSafeVerify总开关关闭，买家用户验证安全服务关闭不生效,通过");
		try {
			Logger.comment("前置条件准备");
			authWapper.updateNewLoginSafeConfiguration("Buyer", "Safe", "Open", "0");
			flushSpac();

			String ip = TestDataManager.getRandomIp();
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setClientIp(ip);
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			String UserName = regbean.getLoginId();

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setClientIp(ip);
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_005() {
		Logger.start(true, "风控验证-TOKEN最后验证时间authtime大于90天UserDeviceTokenAuthHistory，买家用户风控");
		try {
			Logger.comment("前置条件准备");
			flushSpac();
			String phone = TestDataManager.getPhoneNum();
			String email = TestDataManager.getEmail();
			String ip = "1.1.10." + (new Random().nextInt(98) + 1);// China,Guangdong,*
			UserRegisterInfoRequestDtoBean urb = JUserCallService.initUserRegisterInfoRequestDtoBean();
			urb.setClientIp(ip);
			urb.setLoginMobile(phone);
			urb.setLoginMail(email);
			UserRegisterInfoRequestDtoCall u = JUserCallService.UserRegisterInfoRequestDtoCall(urb);
			int userId = u.getUserid();
			Logger.comment("如果认证数据库中不存在该IP的Token记录，则插入token数据，并将token的最后更新时间更改为90天以前");
			Map<String, Object> ipAuth = authWapper.getIPAuthByUserIdAndArea(userId, "China", "Guangdong", "*");
			String dateTime = YMTDateUtil.getBeforeOrNextDay(-100);
			if (ipAuth == null) {
				authWapper.insertIPTokenAuthHistory(userId, "China", "Guangdong", "*", dateTime, dateTime);
				authWapper.insertUserIpAuth(userId, "China", "Guangdong", "*", 200, dateTime, dateTime, "app", dateTime, dateTime);
			} else {
				authWapper.updateTokenUpdateTime(userId, "China", "Guangdong", "*", dateTime);
			}
			String UserName = urb.getLoginId();

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setTokenSource("app");
			lab.setClientIp(ip);
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(100, lac.getErrorCode(), "验证ErrorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_006() {
		Logger.start(true, "风控验证-buyerTokenVerify开关关闭,token认证不生效,通过");
		try {
			Logger.comment("前置条件准备");
			authWapper.updateNewLoginSafeConfiguration("Buyer", "Token", "Open", "0");
			boolean btokenOpenCheck = flushSpac().get("buyerSafeSpec").getAsJsonObject().get("tokenOpenCheck").getAsBoolean();
			int redo = 0;
			while (btokenOpenCheck && redo < ret) {
				Thread.sleep(1000);
				authWapper.updateNewLoginSafeConfiguration("Buyer", "Token", "Open", "0");
				btokenOpenCheck = flushSpac().get("buyerSafeSpec").getAsJsonObject().get("tokenOpenCheck").getAsBoolean();
				redo++;
			}
			String ip = "1.1.10." + (new Random().nextInt(98) + 1);// China,Guangdong,*
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setClientIp(ip);
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			String UserName = regbean.getLoginId();
			int userId = urrc.getUserid();

			ULC201406Wapper userWapper = new ULC201406Wapper();
			ULC201406Bean user = userWapper.getULCInfoByUid(userId);

			Logger.comment("如果认证数据库中不存在该IP的Token记录，则插入token数据，并将token的最后更新时间更改为90天以前");
			Map<String, Object> ipAuth = authWapper.getIPAuthByUserIdAndArea(userId, "China", "Guangdong", "*");
			String dateTime = YMTDateUtil.getBeforeOrNextDay(-100);
			if (ipAuth == null) {
				authWapper.insertIPTokenAuthHistory(userId, "China", "Guangdong", "*", dateTime, dateTime);
				authWapper.insertUserIpAuth(userId, "China", "Guangdong", "*", 200, dateTime, dateTime, "app", dateTime, dateTime);
			} else {
				authWapper.updateTokenUpdateTime(userId, "China", "Guangdong", "*", dateTime);
			}

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setClientIp(ip);
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_007() {
		Logger.start(true, "风控验证-设备号拉黑Ymt_BlacklistUser_201410.YmatouBlacklist_Ip._id,买家用户风控");
		try {
			Logger.comment("前置条件准备");
			authWapper.updateNewLoginSafeConfiguration("Buyer", "DeviceBlacklist", "Open", "1");
			boolean deviceBlacklistOpenCheck = flushSpac().get("buyerSafeSpec").getAsJsonObject().get("deviceBlacklistOpenCheck").getAsBoolean();

			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regbean.setEquimentid(TestDataManager.getRandomUUID().toString());
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			String UserName = regbean.getLoginId();

			YmatouBlacklistUserWapper ymtblacklist = new YmatouBlacklistUserWapper();
			ymtblacklist.saveData(regbean.getDeviceId(), YMTDateUtil.getDateForMongoFormat(-1, 0, 0), YMTDateUtil.getDateForMongoFormat(-1, 0, 0),
					YMTDateUtil.getDateForMongoFormat(1, 0, 0), false, 1);
			Thread.sleep(3000);

			Logger.comment("开始登陆认证");

			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setDeviceId(regbean.getDeviceId());
			lab.setTokenSource("app");
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(100, lac.getErrorCode(), "验证ErrorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_008() {
		Logger.start(true, "风控验证-buyerDeviceBlacklistVerify开关关闭,deviceid黑名单认证不生效,通过");
		try {
			Logger.comment("前置条件准备");

			YmatouBlacklistUserWapper ymtblacklist = new YmatouBlacklistUserWapper();

			authWapper.updateNewLoginSafeConfiguration("Buyer", "DeviceBlacklist", "Open", "0");
//			boolean deviceBlacklistOpenCheck = flushSpac().get("buyerSafeSpec").getAsJsonObject().get("deviceBlacklistOpenCheck").getAsBoolean();
//			int redo = 0;
//			while (deviceBlacklistOpenCheck && redo < ret) {
//				Thread.sleep(1000);
//				authWapper.updateNewLoginSafeConfiguration("Buyer", "DeviceBlacklist", "Open", "0");
//				deviceBlacklistOpenCheck = flushSpac().get("buyerSafeSpec").getAsJsonObject().get("deviceBlacklistOpenCheck").getAsBoolean();
//				redo++;
//			}
			Thread.sleep(1000);
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			String UserName = regbean.getLoginId();

			ymtblacklist.saveData(regbean.getDeviceId(), YMTDateUtil.getDateForMongoFormat(-1, 0, 0), YMTDateUtil.getDateForMongoFormat(-1, 0, 0),
					YMTDateUtil.getDateForMongoFormat(1, 0, 0), false, 1);
			Thread.sleep(3000);

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
//	@Ignore
	public void Tc_LoginAuth_009() {
		Logger.start(true, "风控验证-登入密码错误次数超限,买家用户风控");
		try {
			Logger.comment("前置条件准备");
			new UserSafeWapper().updateRiskStrategyStatus(2, "BuyerLoginCountVerifyStrategy");
			String ip = "1.1.10." + (new Random().nextInt(10) + 1);// China,Guangdong,*

			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setClientIp(ip);
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer uid=urrc.getUserid();
			String UserName = regbean.getLoginId();

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setClientIp(ip);
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			int i = 0;
			while (i < 15) {
				lab.setPas("12345622");
				lac.setData(lab);
				lac.callService();
				i++;
			}
			lab.setPas(JUserCallService.defaultLoginPwd);
			lac.setData(lab);
			lac.callService();
			Thread.sleep(2000);
			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			if (lac.getErrorCode().equals(100)) {
				Logger.verifyEquals(100, lac.getErrorCode(), "验证ErrorCode");
				// 缺少超限提示
				Logger.verifyIsContains("1700", lac.getJsonObject().get("Result").getAsJsonObject().get("LoginRiskCode").getAsString(), "验证LoginRiskCode");
			} else if (lac.getErrorCode().equals(1)) {
				Logger.verifyEquals(1, lac.getErrorCode(), "验证ErrorCode");
				// 登入频繁
				Logger.verifyIsContains("登录频繁请休息会", lac.getJsonObject().get("LastErrorMessage").getAsString(), "验证LastErrorMessage");
				Thread.sleep(2000);
				List<LoginLog> log = new JUserWapper().selectLastLoginLogByLoginId(UserName);
				Logger.debug(FormatUtil.beanToGSONString(log));
				Logger.verifyEquals("登录失败：登录频繁请休息会", log.get(0).getResponseDesc(), "验证ResponseDesc");
				Logger.verifyEquals(1700, log.get(0).getResponseCode(), "验证ResponseCode");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_010() {
		Logger.start(true, "风控验证-登buyerLoginPasFailHistoryVerify开关关闭,登入密码错误次数风控不生效,通过");
		try {
			Logger.comment("前置条件准备");

			authWapper.updateNewLoginSafeConfiguration("Buyer", "LoginPas", "Open", "0");

			boolean loginPasOpenCheck = flushSpac().get("buyerSafeSpec").getAsJsonObject().get("loginPasOpenCheck").getAsBoolean();
			int redo = 0;
			while (loginPasOpenCheck && redo < ret) {
				Thread.sleep(1000);
				authWapper.updateNewLoginSafeConfiguration("Buyer", "LoginPas", "Open", "0");
				loginPasOpenCheck = flushSpac().get("buyerSafeSpec").getAsJsonObject().get("loginPasOpenCheck").getAsBoolean();
				redo++;
			}
			flushSpac();

			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			int userId = urrc.getUserid();
			String UserName = regbean.getLoginId();
			String ip = regbean.getClientIp();

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas("12345622");
			lab.setSourceType("app");
			lab.setClientIp(ip);

			int i = 0;
			while (i < 10) {
				lac.setData(lab);
				lac.callService();
				i++;
			}

			lab.setPas(JUserCallService.defaultLoginPwd);
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_011() {
		Logger.start(true, "未激活用户，登入认证成功");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			int UserId = urrc.getUserid();

			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());

			new JUserWapper().setUserStateOfUserInfo(UserId, -1);

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_012() {
		Logger.start(true, "锁定用户，登入认证失败");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();

			Date now = new Date();

			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());

			new JUserWapper().setUserStateOfUserInfo(UserId, 1);

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_013() {
		Logger.start(true, "已注销用户，登入认证失败");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();

			Date now = new Date();

			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());

			new JUserWapper().setUserStateOfUserInfo(UserId, 2);

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_014() {
		Logger.start(false, "非空验证-LoginId");
		try {

			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setClientIp(TestDataManager.getRandomIp());
			lab.setSourceType("app");

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("错误的请求参数|登录名需要提供", lac.getString("LastErrorMessage"), "验证Code信息");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_015() {
		Logger.start(false, "非空验证-Pas");
		try {

			lab.setLoginId("nobody1");
			lab.setClientIp(TestDataManager.getRandomIp());
			lab.setSourceType("app");

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("错误的请求参数|登录密码需要提供", lac.getString("LastErrorMessage"), "验证Code信息");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_016() {
		Logger.start(false, "非空验证-ClientIp");
		try {
			lab.setLoginId("nobody1");
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("错误的请求参数|客户端Ip需要提供", lac.getString("LastErrorMessage"), "验证Code信息");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_017() {
		Logger.start(false, "LoginId检查-不含@");
		try {
			lab.setLoginId("nobody@1");
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setClientIp(TestDataManager.getRandomIp());
			lab.setSourceType("app");

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("用户名或密码错误", lac.getString("LastErrorMessage"), "验证Code信息");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_018() {
		Logger.start(false, "LoginId检查-不能超过最大长度限制");
		try {
			lab.setLoginId(
					"nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1nobody1");
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setClientIp(TestDataManager.getRandomIp());
			lab.setSourceType("app");

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("非法的登录名", lac.getString("LastErrorMessage"), "验证Code信息");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_019() {
		Logger.start(false, "LoginId检查-不能超过最大长度限制——中文");
		try {
			lab.setLoginId("去死去死去死去死去死去死去死去死去死去死去死");
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setClientIp(TestDataManager.getRandomIp());
			lab.setSourceType("app");

			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("非法的登录名", lac.getString("LastErrorMessage"), "验证Code信息");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_020() {
		Logger.start(false, "SourceType=userservice.ymatou.com,只做基本认证，不做风控");
		try {

			Logger.comment("前置条件准备");
			flushSpac();
			String phone = TestDataManager.getPhoneNum();
			String email = TestDataManager.getEmail();
			String ip = "1.1.10." + (new Random().nextInt(98) + 1);// China,Guangdong,*

			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			int userId = urrc.getUserid();
			String UserName = regbean.getLoginId();

			Logger.comment("如果认证数据库中不存在该IP的Token记录，则插入token数据，并将token的最后更新时间更改为90天以前");
			Map<String, Object> ipAuth = authWapper.getIPAuthByUserIdAndArea(userId, "China", "Guangdong", "*");
			String dateTime = YMTDateUtil.getBeforeOrNextDay(-100);
			if (ipAuth == null) {
				authWapper.insertIPTokenAuthHistory(userId, "China", "Guangdong", "*", dateTime, dateTime);
				authWapper.insertUserIpAuth(userId, "China", "Guangdong", "*", 200, dateTime, dateTime, "app", dateTime, dateTime);
			} else {
				authWapper.updateTokenUpdateTime(userId, "China", "Guangdong", "*", dateTime);
			}

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("userservice.ymatou.com");
			lab.setClientIp(ip);
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	//风控case重构
	public void Tc_LoginAuth_021() {
		Logger.start(false, "SourceType=PC走PC风控");
		try {

			Logger.comment("风控case重构,作废");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_022() {
		Logger.start(false, "买家为Iphone7,跳过风控");
		try {

			Logger.comment("deviceid增加条IOS7的记录");
			SaveBean saveBean = DeviceidCallService.setDefaultFullSaveBean();

			SaveCall saveCall = DeviceidCallService.saveCall(saveBean);

			Logger.comment("前置条件准备");
			flushSpac();
			String phone = TestDataManager.getPhoneNum();
			String email = TestDataManager.getEmail();
			String ip = "1.1.10." + (new Random().nextInt(98) + 1);// China,Guangdong,*

			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			int userId = urrc.getUserid();
			String UserName = regbean.getLoginId();

			Logger.comment("如果认证数据库中不存在该IP的Token记录，则插入token数据，并将token的最后更新时间更改为90天以前");
			Map<String, Object> ipAuth = authWapper.getIPAuthByUserIdAndArea(userId, "China", "Guangdong", "*");
			String dateTime = YMTDateUtil.getBeforeOrNextDay(-100);
			if (ipAuth == null) {
				authWapper.insertIPTokenAuthHistory(userId, "China", "Guangdong", "*", dateTime, dateTime);
				authWapper.insertUserIpAuth(userId, "China", "Guangdong", "*", 200, dateTime, dateTime, "app", dateTime, dateTime);
			} else {
				authWapper.updateTokenUpdateTime(userId, "China", "Guangdong", "*", dateTime);
			}

			Logger.comment("开始登陆认证");
			lab.setLoginId(UserName);
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("matise");
			lab.setClientIp(ip);
			lab.setDeviceId(saveBean.getDeviceid());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_023() {
		Logger.start(true, "注册用户第一次在PC端登陆,5分钟超过10次报次数超限制");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");

			for (int i = 0; i < 12; i++) {
				lac.setData(lab);
				lac.callService();
			}

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("登录频繁请休息会", lac.getLastErrorMessage(), "验证LastErrorMessage");
			Logger.verifyEquals(1, lac.getErrorCode(), "验证ErrorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_024() {
		Logger.start(true, "风控验证-黑名单用户登录失败-该功能已注释掉");
		try {

			Logger.comment("开始登陆认证");
			lab.setLoginId(EnvSetup.getData("black_user_id"));
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setClientIp("127.0.0.1");
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("请执行身份校验", lac.getLastErrorMessage(), "验证LastErrorMessage");
			Logger.verifyEquals(100, lac.getErrorCode(), "验证ErrorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_LoginAuth_025() {
		Logger.start(true, "风控验证-同一IP，50次登录成功，51次时进IP黑名单");
		try {

			Logger.comment("开始登陆认证");
			String ip = "172.16.105.127";
			Logger.comment("前置条件准备");
			for (int i = 0; i < 50; i++) {
				UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
				regbean.setClientIp(ip);
				UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
				JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
				// String token=result.get("Token").getAsString();
				lac = new LoginAuthCall();
				Logger.comment("开始登陆认证");
				lab.setLoginId(regbean.getLoginId());
				lab.setPas(regbean.getPas());
				lab.setSourceType("app");
				lab.setClientIp(regbean.getClientIp());
				lab.setTSource("ios");
				lab.setTokenSource("app");
				lac.setData(false,lab);

				lac.callService();
			}
			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("请执行身份校验", lac.getLastErrorMessage(), "验证LastErrorMessage");
			Logger.verifyEquals("140", lac.getLoginRiskCode(), "验证ErrorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//未设置白名单
	public void Tc_LoginAuth_026() {
		Logger.start(true, "风控验证-用户白名单");
		try {

			Logger.comment("开始登陆认证");
			String ip = "172.16.105.127";

			Logger.comment("开始登陆认证");
			lab.setLoginId(EnvSetup.getData("while_user_id").toString());
			lab.setPas(JUserCallService.defaultLoginPwd);
			lab.setSourceType("app");
			lab.setClientIp(ip);
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lac.setData(lab);

			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("请执行身份校验", lac.getLastErrorMessage(), "验证LastErrorMessage");
			Logger.verifyEquals("140", lac.getLoginRiskCode(), "验证ErrorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//设备号黑名单控制？
	public void Tc_LoginAuth_027() {
		Logger.start(true, "风控验证-同一Deviceid，十分钟6次登录成功，7次时进IP黑名单");
		try {
			Logger.comment("前置条件准备");
			String did=TestDataManager.getRandomUUID().toString();
			for (int i = 0; i < 50; i++) {
				UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
				regbean.setDeviceId(did);
				UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
				JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
				String token = result.get("Token").getAsString();
				Logger.comment("开始登陆认证");
				lab.setLoginId(regbean.getLoginId());
				lab.setPas(regbean.getPas());
				lab.setSourceType("app");
				lab.setClientIp(regbean.getClientIp());
				lab.setTSource("ios");
				lab.setTokenSource("app");
				lab.setDeviceId(regbean.getDeviceId());
				lac.setData(false, lab);
				Logger.comment("第" + (i + 1) + "次认证");
				lac.callService();
//				Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			}

			lac.callService();
			if (lac.getErrorCode().equals(100)) {
				Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
				Logger.verifyEquals("请执行身份校验", lac.getLastErrorMessage(), "验证LastErrorMessage");
				Logger.verifyEquals("162", lac.getLoginRiskCode(), "验证ErrorCode");
			} else if (lac.getErrorCode().equals(1)) {
				Logger.verifyEquals(1, lac.getErrorCode(), "验证ErrorCode");
				// 登入频繁
				Logger.verifyIsContains("登录频繁请休息会", lac.getJsonObject().get("LastErrorMessage").getAsString(), "验证LastErrorMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//JIRACONN-14171 去除防撞库
	public void Tc_LoginAuth_028() {
		Logger.start(true, "app注册用户第一次在pc端登陆，防撞库风控JIRACONN-12032");
		try {
			JUserSafe.initConfig(2);
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			//app注册
			regbean.setRegSource(1);
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("Mainsite");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("MainSite");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("120", lac.getLoginRiskCode(), "验证ErrorCode");
			Logger.verifyIsContains("请执行身份校验", lac.getJsonObject().get("LastErrorMessage").getAsString(), "验证LastErrorMessage");
//			JUserSafe.authIPArea(regbean.getClientIp(), regbean.getLoginId(), regbean.getPas(), "wap");
//			lac.callService();
//			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//JIRACONN-14171 去除防撞库
	public void Tc_LoginAuth_029() {
		Logger.start(true, "pc注册用户第一次在pc端登入，成功(pc或wap)JIRACONN-12032");
		try {
			JUserSafe.initConfig(2);
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setRegSource(0);
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("MainSite");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("MainSite");
//			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//JIRACONN-14171 去除防撞库
	public void Tc_LoginAuth_030() {
		Logger.start(true, "wap注册用户第一次在wap端登陆，成功JIRACONN-12032");
		try {
			JUserSafe.initConfig(2);
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			//app注册
			regbean.setRegSource(2);
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("wap");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("wap");
//			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
//			Logger.verifyEquals("155", lac.getLoginRiskCode(), "验证ErrorCode");
//			Logger.verifyIsContains("请执行身份校验", lac.getJsonObject().get("LastErrorMessage").getAsString(), "验证LastErrorMessage");
//			JUserSafe.authIPArea(regbean.getClientIp(), regbean.getLoginId(), regbean.getPas(), "wap");
//			lac.callService();
//			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_031() {
		Logger.start(true, "JIRACONN-17316, ios11系统免认证");
		try {
			Logger.comment("前置条件准备");

			com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean urb = JUserCallService.initUserRegisterInfoRequestDtoBean();
			urb.setTokenSource("app");
			UserRegisterInfoRequestDtoCall uc = JUserCallService.UserRegisterInfoRequestDtoCall(urb);
			Integer UserId = uc.getUserid();
			String AccessToken=uc.getAccessToken();
			
			String UserName = urb.getLoginMobile();
			String ip=urb.getClientIp();
			
			String deviceId = TestDataManager.getRandomNum(6);
			Logger.comment("如果设备已认证过，则删除此认证数据");
			authWapper.deleteDeviceData(UserId, deviceId);
			// osversion = "ios10.x" && signVerified == 2
			Logger.comment("设置设备信息");
			SaveBean saveBean=DeviceidCallService.setDefaultFullSaveBean();
			saveBean.setDeviceid(deviceId);
			saveBean.setUserid(UserId);
			saveBean.setOsversion("ios11.1");
			DeviceidCallService.saveCall(saveBean);
			Logger.comment("登陆此用户");
			lab.setLoginId(urb.getLoginId());
			lab.setPas(urb.getPas());
			lab.setClientIp("1.1.9.1");
			lab.setSourceType("app");
			lab.setDeviceId(deviceId);
			lab.setClientId("aaaa");
			lac.setData(lab);
			lac.callService();
			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(urb.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(AccessToken, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(urb.getLoginId(), lac.getUserData().getLoginId(), "验证登陆ID");
			Logger.verifyEquals(urb.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(AccessToken, lac.getUserData().getSign(), "验证Token信息-登入后重新生成");
			Map<String, Object> info = authWapper.getIPAuthByUserIdAndArea(UserId, null, null, null);
			Logger.verifyEquals(String.valueOf(UserId), info.get("UserId").toString(), "验证UserId信息");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_032() {
		Logger.start(true, "JIRACONN-2123 ios10系统免认证");
		try {
			Logger.comment("前置条件准备");

			com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean urb = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall uc = JUserCallService.UserRegisterInfoRequestDtoCall(urb);
			Integer UserId = uc.getUserid();
			String AccessToken=uc.getAccessToken();
			
			String UserName = urb.getLoginMobile();
			String ip=urb.getClientIp();
			
			String deviceId = TestDataManager.getRandomNum(6);
			Logger.comment("如果设备已认证过，则删除此认证数据");
			authWapper.deleteDeviceData(UserId, deviceId);
			// osversion = "ios10.x" && signVerified == 2
			Logger.comment("设置设备信息");
			SaveBean saveBean=DeviceidCallService.setDefaultFullSaveBean();
			saveBean.setDeviceid(deviceId);
			saveBean.setUserid(UserId);
			saveBean.setOsversion("ios10.1");
			DeviceidCallService.saveCall(saveBean);
			Logger.comment("登陆此用户");
			lab.setLoginId(urb.getLoginId());
			lab.setPas(urb.getPas());
			lab.setClientIp("1.1.9.1");
			lab.setSourceType("app");
			lab.setDeviceId(deviceId);
			lab.setClientId("aaaa");
			lac.setData(lab);
			lac.callService();
			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(urb.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(AccessToken, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(urb.getLoginId(), lac.getUserData().getLoginId(), "验证登陆ID");
			Logger.verifyEquals(urb.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(AccessToken, lac.getUserData().getSign(), "验证Token信息-登入后重新生成");
			Map<String, Object> info = authWapper.getIPAuthByUserIdAndArea(UserId, null, null, null);
			Logger.verifyEquals(String.valueOf(UserId), info.get("UserId").toString(), "验证UserId信息");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_LoginAuth_033() {
		Logger.start(false, "liveshop直播微店商户不能登入码头");
		try {
			SellerRegisterBean srb=LiveShopUserCallService.initSellerReg();
			LiveShopUserCallService.LiveShopSellerRegister(srb);
			lab.setLoginId(srb.getLoginId());
			lab.setPas(srb.getPassword());
			lab.setClientIp(srb.getClientIp());
			lac.setData(lab);
			lab.setSourceType("app");
			lac.callService();
			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("InvalidUserSystem", new JSONObject(lac.getString("Result")).get("Code"), "验证Code信息");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_034() {
		Logger.start(true, "注册用户第一次在PC端登陆，登入认证成功,使用加密密码");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setTokenSource("app");
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			String pwd = DesUtil.encrypt(regbean.getPas(),DesUtil.DES_KEY_STRING,DesUtil.DES_IVPARAMETER);
			Logger.comment("开始登陆认证");
			lab.setPasswordType(1);
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(pwd);
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(token, lac.getUserData().getSign(), "验证Token信息-登入后重新生成");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(UserId).get(0);

			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regbean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_035() {
		Logger.start(false, "注册用户第一次在PC端登陆,使用加密密码错误失败");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			String pwd = DesUtil.encrypt(regbean.getPas(),DesUtil.DES_KEY_STRING,DesUtil.DES_IVPARAMETER);
			Logger.comment("开始登陆认证");
			lab.setPasswordType(1);
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(pwd+1);
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();
			Logger.verifyEquals(false, lac.getSuccess(), "验证Success");
			Logger.verifyEquals("用户名或密码错误", lac.getLastErrorMessage(), "验证LastErrorMessage");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//密码规则下沉底层服务 现在特殊字符密码不可用注册失败
	public void Tc_LoginAuth_036() {
		Logger.start(true, "注册用户第一次在PC端登陆，登入认证成功,使用加密密码,密码包含特殊字符");
		try {
			Logger.comment("前置条件准备");
			String pwd = DesUtil.encrypt("12345=_#",DesUtil.DES_KEY_STRING,DesUtil.DES_IVPARAMETER);
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setPas(pwd);
			regbean.setPasswordType(1);
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			
			Logger.comment("开始登陆认证");
			lab.setPasswordType(1);
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(pwd);
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyEquals(token, lac.getUserData().getSign(), "验证Token信息");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(UserId).get(0);

			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regbean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_037() {
		Logger.start(true, "注册用户登入认证成功,AppLive11来自码头App直播版本");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setTokenSource("app");
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("AppLive");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(token, lac.getUserData().getSign(), "验证Token信息-登入重新生成");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(UserId).get(0);

			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regbean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_038() {
		Logger.start(true, "注册用户第一次在PC端登陆，登入认证成功,使用加密密码2");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setTokenSource("app");
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			  byte[] rsabytes = RSAUtils.encryptByPublicKey(regbean.getPas().getBytes(),
						(RSAPublicKey) RSAUtils.loadPublicKey(EnvSetup
								.getData("USER_PUBLIC_KEY")));
				String rsanpwd = Base64.getEncoder().encodeToString(rsabytes);
			Logger.comment("开始登陆认证");
			lab.setPasswordType(2);
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(rsanpwd);
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(token, lac.getUserData().getSign(), "验证Token信息-登入重新生成");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(UserId).get(0);

			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regbean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_039() {
		Logger.start(true, "注册用户第一次在app端登陆，不输入deviceid,自动生成deviceid,登入认证成功");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setTokenSource("pc");
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			Integer UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(token, lac.getUserData().getSign(), "验证Token信息-登入重新生成");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(UserId).get(0);

			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			//这个场景deviceid实际是不传的 日志中不记录
			Logger.verifyEquals(null, loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
			
			Map<String, Object> tm = userTokenWapper.getUserTokenByUid(UserId);
			Logger.verifyIsContains(UserId.toString(), tm.get("deviceId"), "验证自动生成的deviceId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_040() {
		Logger.start(true, "注册用户第一次在PC端登陆，登入认证成功-TerminalSource为null时入库0");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setTokenSource("app");
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
//			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(token, lac.getUserData().getSign(), "验证Token信息-登入重新生成");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			List<LoginLog> loginLogs = new JUserWapper().selectLastLoginLogByUid(UserId);
			Logger.debug("log:"+FormatUtil.beanToGSONString(loginLogs));
			LoginLog loginLog=loginLogs.get(0);
			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(0, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regbean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LoginAuth_041() {
		Logger.start(true, "注册用户第一次在PC端登陆，登入认证成功-新增字段clientport");
		try {
			Logger.comment("前置条件准备");
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			regbean.setTokenSource("app");
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject result = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = result.get("Token").getAsString();
			int UserId = urrc.getUserid();
			JUserCallService.UpdateTradingPwd(UserId, "abc123");
			Date now = new Date();
			Thread.sleep(3000);
			Logger.comment("开始登陆认证");
			lab.setClientPort("99998");
			lab.setLoginId(regbean.getLoginId());
			lab.setPas(regbean.getPas());
			lab.setSourceType("app");
			lab.setClientIp(regbean.getClientIp());
			lab.setTSource("ios");
			lab.setTokenSource("app");
			lab.setDeviceId(regbean.getDeviceId());
			lac.setData(lab);
			lac.callService();

			Logger.verifyEquals(true, lac.getSuccess(), "验证Success");
			Logger.verifyEquals(regbean.getLoginMobile(), lac.getUserData().getLoginMobile(), "验证UserName");
			Logger.verifyNotNull(token, "验证AccessToken");
			Logger.verifyEquals(UserId, lac.getUserData().getUserId(), "验证UserId");
			Logger.verifyEquals(regbean.getLoginMail(), lac.getUserData().getLoginMail(), "验证登录邮箱");
			Logger.verifyNotEquals(token, lac.getUserData().getSign(), "验证Token信息-登入重新生成");
			Logger.verifyNotNull(lac.getUserData().getTradingPassword(), "验证TradingPassword信息");
			// Logger.verifyEquals(128, lac.getUserData().getSign().length(),
			// "验证新Token长度");
			// 验证UserInfo表中LastUpdateTime
			Userinfo userinfo = new JUserWapper().selectUserinfoByUid(UserId).get(0);
			Logger.verifyNotNull(userinfo.getLastLoginTime(), "验证UserInfo表中LastUpdateTime");
			// Logger.verifyEquals(false, userinfo.getLastLoginTime().after(new
			// Date()), "验证UserInfo表中LastUpdateTime");

			// 验证LoginLog表中新增一条记录
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(UserId).get(0);
//			System.out.println(FormatUtil.beanToGSONString(loginLog));
			Logger.verifyEquals(userinfo.getLoginId(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(lab.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			Logger.verifyEquals(lab.getClientPort(), loginLog.getClientPort(), "验证LoginLog表中getClientPort");
			// 码头登陆的为0
			Logger.verifyEquals(0, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regbean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (lac.getResponseCode() == 0) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} else {
				Logger.verifyEquals(lac.getLastErrorMessage(), loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(lac.getResponseCode(), loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			}
			// 风控返回
			// Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(regbean.getRegisterType(), loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	/**
	 * 删除Ip黑名单，删除IP在一段时间内的历史记录
	 * 
	 * @param ip
	 *            IP
	 * @param dateTime
	 *            删除此时间之后的历史记录（从现在到dateTime为止的历史记录）
	 * @throws Exception
	 */
	public void checkIpLoginHistory(String ip, String dateTime) throws Exception {
		if (DELETELOGINHISTORY) {
			ymtblacklistuserWapper.deleteData(ip);
			mloginHistoryWapper.deleteByIp(ip, dateTime);
		}
	}

	/**
	 * 删除设备黑名单，删除设备在一段时间内的历史记录
	 * 
	 * @param deviceId
	 *            设备Id
	 * @param dateTime
	 *            删除此时间之后的历史记录（从现在到dateTime为止的历史记录）
	 * @throws Exception
	 */
	public void checkDeviceLoginHistory(String deviceId, String dateTime) throws Exception {
		if (DELETELOGINHISTORY) {
			ymtblacklistuserWapper.deleteData(deviceId);
			mloginHistoryWapper.deleteByDeviceId(deviceId, dateTime);
		}
	}

	/**
	 * 删除用户黑名单，删除用户在一段时间内的登陆记录
	 * 
	 * @param uId
	 *            用户Id
	 * @param loginId
	 *            登陆Id
	 * @param dateTime
	 *            删除此时间之后的历史记录（从现在到dateTime为止的历史记录）
	 * @throws Exception
	 */
	public void checkLoginIDLoginHistory(int uId, String loginId, String dateTime) throws Exception {
		if (DELETELOGINHISTORY) {
			ymtblacklistuserWapper.deleteData(uId);
			mloginHistoryWapper.deleteByLoginId(loginId, dateTime);
		}
	}

	/**
	 * 重新加载配置
	 * 
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 * @throws InterruptedException
	 */
	public JsonObject flushSpac() throws ClientProtocolException, IOException, InterruptedException {
		String url = "http://usersafe.iapi.ymatou.com/flushspec";
		YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
		ec.callService();
		Thread.sleep(6000);
		return ec.getJsonObject();
	}
}